<template>
  <el-dialog title="打印" :visible.sync="openOne" width="800px" append-to-body :before-close="close">
    <div v-if="list" id="printMe" class="main1">
      <div class="title">
        <p class="zi1">南京综保区跨境电子商务发展有限公司</p>
      </div>
      <div style="float:left;width:555px;">
        <p class="title2">INBOUND TALLY SHEET</p>
      </div>
      <div class="area">
        <div class="column">
          <p class="zi1">工作号:</p>
          <p class="zi2">{{ list.job_number }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">业务类型:</p>
          <p class="zi2" v-if="list.business_type=='AE'">空运出口</p>
          <p class="zi2" v-if="list.business_type=='AI'">空运进口</p>
          <p class="zi2" v-if="list.business_type=='SE'">海运出口</p>
          <p class="zi2" v-if="list.business_type=='SI'">海运进口</p>
          <p class="zi2" v-if="list.business_type=='NM'">内贸业务</p>
          <p class="zi2" v-if="list.business_type=='BS'">保税业务</p>
          <p class="zi2" v-if="list.business_type=='BG'">报关业务</p>
        </div>
        <div class="column">
          <p class="zi1">业务状态:</p>
          <p class="zi2" v-if="list.business_status==1">NEW</p>
          <p class="zi2" v-if="list.business_status==2">未知</p>
        </div>
        <div class="column column2">
          <p class="zi1">订单状态:</p>
          <p class="zi2" v-if="list.order_status==1">NEW</p>
          <p class="zi2" v-if="list.order_status==2">未知</p>
        </div>
        <div class="column">
          <p class="zi1">委托单位:</p>
          <p class="zi2">{{ list.entrust_company }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">经营单位:</p>
          <p class="zi2">{{ list.management_company }}</p>
        </div>
        <div class="column">
          <p class="zi1">内部类型:</p>
          <p class="zi2">{{ list.inside_type }}</p>
        </div>
        <div class="column column2">
          <p class="zi1">项目类型:</p>
          <p class="zi2">{{ list.project_type }}</p>
        </div>
        <div class="column">
          <p class="zi1">委托日期:</p>
          <p class="zi2">{{ list.entrust_date }}</p>
        </div>
      </div>
      <hr style="float:left;width:555px;margin-top:5px;">
      <div v-if="list" class="form">
        <div class="area">
          <div class="column">
            <p class="zi1">发货人:</p>
            <p class="zi2">{{ list.consignor }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">收货人:</p>
            <p class="zi2">{{ list.consignee }}</p>
          </div>
          <div class="column">
            <p class="zi1">通知人:</p>
            <p class="zi2">{{ list.notifier }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">目的港:</p>
            <p class="zi2">{{ list.objective_harbor }}</p>
          </div>
          <div class="column">
            <p class="zi1">航线:</p>
            <p class="zi2">{{ list.route }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">订舱代理:</p>
            <p class="zi2">{{ list.booking_agent }}</p>
          </div>
          <div class="column">
            <p class="zi1">主单号:</p>
            <p class="zi2">{{ list.main_doc_no }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">分单号:</p>
            <p class="zi2">{{ list.sub_order_No }}</p>
          </div>
          <div class="column">
            <p class="zi1">体积:</p>
            <p class="zi2">{{ list.volume }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">件数:</p>
            <p class="zi2">{{ list.number }}</p>
          </div>
          <div class="column">
            <p class="zi1">包装:</p>
            <p class="zi2">{{ list.packing }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">毛重:</p>
            <p class="zi2">{{ list.gross_weight }}</p>
          </div>
          <div class="column">
            <p class="zi1">提单要求:</p>
            <p class="zi2">{{ list.lading_bill_ask }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">提单信息:</p>
            <p class="zi2">{{ list.lading_bill_info }}</p>
          </div>
          <div class="column">
            <p class="zi1">提单号:</p>
            <p class="zi2">{{ list.lading_bill_num }}</p>
          </div>
          <div class="column column2">
            <p class="zi1">备注:</p>
            <p class="zi2">{{ list.remarks }}</p>
          </div>
        </div>
      </div>
      <div>
      <table class="collapsed" v-if="list.transports.length>0">
        <thead>
        <tr>
          <th>起运时间</th>
          <th>箱型箱量</th>
          <th>运输公司</th>
          <th>车号</th>
          <th>运单状态</th>
          <th>状态时间</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(item,index) in list.transports" :key="index">
          <td>{{ item.departure_date }}</td>
          <td>{{ item.box_type_volume }}</td>
          <td>{{ item.transport_company }}</td>
          <td>{{ item.wagon_number }}</td>
          <td>{{ item.waybill_status }}</td>
          <td>{{ item.status_date }}</td>
        </tr>
        </tbody>
      </table>
      </div>

      <div class="tail">
        <div class="nr1">
          <p class="zi1">创建人:</p>
          <p class="zi2">{{ list.creator }}</p>
        </div>
        <div class="nr1">
          <p class="zi1">创建时间:</p>
          <p class="zi2">{{ list.created_at }}</p>
        </div>
      </div>
    </div>
    <el-row style="top: 30px;margin-bottom: 30px;text-align:center;">
      <el-col :span="24">
        <el-button v-print="'#printMe'" type="primary" size="medium">打印</el-button>
      </el-col>
    </el-row>
  </el-dialog>
</template>
<script>
import { airliftPrint } from '@/api/business'
export default {
  name: 'Print',
  props: {
    openOne: {
      type: Boolean
    },
    id: {
      type: Number
    }
  },
  data() {
    return {
      list: null
    }
  },
  watch: {
    'openOne': function(newValue, oldValue) {
      if (newValue === true) {
        this.printList()
      }
    }
  },
  methods: {
    printList() {
      const that = this
      const data = {
        id: this.id
      }
      airliftPrint(data).then(response => {
        if (response.code === 10000) {
          that.list = response.data
          // console.log(typeof this.list.transports);
        }
      })
    },
    close() {
      this.$emit('update:openOne', false)
    }
  }
}
</script>
<style lang="scss" scoped>
img {
  width: 100%;
  float: left;
}

p {
  padding: 0;
  margin: 0;
  font-family: 宋体
}

div {
  font-family: 宋体;
}

.main1 {
  width: 555px;
  background: #fff;
  padding: 0px 20px;
  margin:auto;
}

.title {
  float: left;
  width: 555px;
  border-bottom: 2px solid #000;
  padding: 10px 0px;
}

.title .logo {
  float: left;
  width: 116px;
  height: 30px;
}

.title .zi1 {
  float:right;
  line-height: 30px;
  font-size: 18px;
  color: #000;
}
.title .zi2 {
  float:right;
  line-height: 30px;
  font-size: 14px;
  color: #999;
  width:555px;
  text-align:right;
}

.title2 {
  float: left;
  line-height: 40px;
  font-size: 18px;
  color: #970000;
}

.title2-1 {
  float:right;
  height: 40px;
  width:200px;
}

.area {
  float: left;
  width: 555px;
}

.area p {
  font-size: 11px;
  line-height: 24px;
}

.area .column {
  float: left;
  width: 272.5px;
  margin-right: 10px;
  margin-bottom: 5px;
}

.area .column .img1{float:left;width:200px;height:40px;margin-left:10px;}

.area .column2 {
  margin-right: 0;
}

.area .zi1 {
  float: left;
  border-bottom: 1px solid #fff;
  width: 100px;
}

.area .zi2 {
  float: left;
  //border-bottom: 1px solid #000;
  width: 160.5px;
  margin-left: 10px;
}

.form {
  float: left;
  width: 555px;
  margin-top: 10px;
}

.form .name {
  float: left;
  width: 555px;
  font-size: 14px;
  line-height:30px;
}

table,
td,
th {
  padding: 3px;
  border: 1px solid #aaa;
  text-align: center;
  font-size: 12px;
  line-height: 18px;
}

th {
  font-weight: bold;
}

.separate {
  border-collapse: separate;
}

.collapsed {
  border-collapse: collapse;
  width: 555px;
}

.tail {
  float: left;
  width: 555px;
  margin-top: 5px;
  margin-bottom: 20px;
}

.tail .nr1 {
  float: left;
  width: 277.5px;
  font-size: 10px;
  line-height: 18px;
}

.tail .nr1 p {
  float: left;
}

.tail .nr1 .zi2 {
  margin-left: 5px;
}
</style>

